package com.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInterceptor;
import com.pojo.User;
import com.service.UserService;
import com.vo.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired(required = false)
    private UserService userService;
    //查询用get请求方式
    @RequestMapping(method = RequestMethod.GET)
    @ResponseBody
    public Msg all(){
        PageHelper.startPage(1,2);
        List<User> ulist = userService.all();
        Msg msg = new Msg();
        msg.setData(ulist);
        msg.setCount(12);
        System.out.println("all");
        return msg;

    }


    //新增用post请求方式
    @RequestMapping(method = RequestMethod.POST)
    public String add(){
        System.out.println("add");
        return "";
    }
    //修改
    @PutMapping
    public String update(){
        System.out.println("update");
        return "";
    }
    //删除
    @DeleteMapping
    public String delete(){
        System.out.println("delete");
        return "";
    }
}
